package  
{
	import org.flixel.*;

	public class PlayState extends FlxState
	{
		public function PlayState() 
		{
			super();
		}
		
		override public function create():void
		{
			super.create();
			
			Registry.init();
			
			add(Registry.background);
			add(Registry.enemyBullets);
			add(Registry.enemies);
			add(Registry.playerBullets);
			add(Registry.fx);
			add(Registry.player);
			add(Registry.hud);
		}
		
		override public function update():void
		{
			super.update();
			
			FlxU.overlap(Registry.playerBullets, Registry.enemies, Registry.enemies.bulletHitEnemy);
			FlxU.overlap(Registry.enemyBullets, Registry.player, Registry.player.bulletHitPlayer);
			
			if (Registry.player.lives == 0 || FlxG.keys.justReleased("Q"))
			{
				FlxG.state = new GameOverState;
			}
			
			//	Debug Testing - these will come from power-ups at some stage
			if (FlxG.keys.justReleased("F1"))
			{
				Registry.player.fireType = 1;
			}
			
			if (FlxG.keys.justReleased("F2"))
			{
				Registry.player.fireType = 2;
			}
			
			if (FlxG.keys.justReleased("F3"))
			{
				Registry.player.fireType = 3;
			}
		}
		
		override public function destroy():void
		{
			Registry.hud.liveUpdate = false;
			
			Registry.destroy();
			
			super.destroy();
		}
		
	}

}